/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SOFTBUS_CLIENT_STUB_H_
#define SOFTBUS_CLIENT_STUB_H_

#include <map>
#include "if_softbus_client.h"
#include "iremote_object.h"
#include "iremote_stub.h"

namespace OHOS {
class SoftBusClientStub : public IRemoteStub<ISoftBusClient> {
public:
    SoftBusClientStub();
    virtual ~SoftBusClientStub() = default;
    int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
    void OnDeviceFound(const void *device) override;
    void OnDiscoverFailed(int subscribeId, int failReason) override;
    void OnDiscoverySuccess(int subscribeId) override;
    void OnPublishSuccess(int publishId) override;
    void OnPublishFail(int publishId, int reason) override;
    int32_t OnChannelOpened(const char *pkgName, const char *sessionName, const void *info) override;
    int32_t OnChannelOpenFailed(const char *pkgName, int32_t channelId) override;
    int32_t OnChannelClosed(const char *pkgName, int32_t channelId) override;
    int32_t OnChannelMsgReceived(const char *pkgName, int32_t channelId, const void *data, uint32_t len,
        int32_t type) override;
    int32_t OnJoinLNNResult(void *addr, uint32_t addrTypeLen, const char *networkId, int retCode) override;
    int32_t OnLeaveLNNResult(const char *networkId, int retCode) override;
    int32_t OnNodeOnlineStateChanged(bool isOnline, void *info, uint32_t infoTypeLen) override;
    int32_t OnNodeBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t type) override;

private:
    int32_t OnDeviceFoundInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnDiscoverFailedInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnDiscoverySuccessInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnPublishSuccessInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnPublishFailInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnChannelOpenedInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnChannelOpenFailedInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnChannelClosedInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnChannelMsgReceivedInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnJoinLNNResultInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnLeaveLNNResultInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnNodeOnlineStateChangedInner(MessageParcel &data, MessageParcel &reply);
    int32_t OnNodeBasicInfoChangedInner(MessageParcel &data, MessageParcel &reply);

    using SoftBusClientStubFunc =
        int32_t (SoftBusClientStub::*)(MessageParcel &data, MessageParcel &reply);
    std::map<uint32_t, SoftBusClientStubFunc> memberFuncMap_;
};
} // namespace OHOS

#endif // SOFTBUS_CLIENT_STUB_H_